import BN from 'bignumber.js';

export const bn = (n: BN.Value | null): BN => new BN(n === null || n === '' ? 0 : n);

export const bnFormat = (n: BN.Value | null) => {
    if (n?.toString().indexOf(".") != -1) return bn(n).toFormat(6)
    return bn(n).toFormat()
};

export const bnFixed = (n: BN.Value | null) => bn(n).toFixed();

export type BigNumber = BN;
